package org.dioib.practice.common.exception;

import lombok.Getter;

import java.util.Arrays;
import java.util.List;

@Getter
public class OrderStatusException extends RuntimeException {
    private final String orderId;
    private final String currentStatus;
    private final List<String> allowedStatuses;

    public OrderStatusException(String orderId, String currentStatus, String... allowedStatuses) {
        super(String.format("Order %s with status '%s' cannot perform this operation. Allowed statuses: %s",
                orderId, currentStatus, Arrays.toString(allowedStatuses)));
        this.orderId = orderId;
        this.currentStatus = currentStatus;
        this.allowedStatuses = Arrays.asList(allowedStatuses);
    }

    public OrderStatusException(String orderId, String currentStatus, List<String> allowedStatuses) {
        super(String.format("Order %s with status '%s' cannot perform this operation. Allowed statuses: %s",
                orderId, currentStatus, allowedStatuses));
        this.orderId = orderId;
        this.currentStatus = currentStatus;
        this.allowedStatuses = allowedStatuses;
    }

}